﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 简单了解Graphics操作
{
    public partial class Form5 : Form
    {
        public Form5()
        {
            InitializeComponent();
        }

        private void Form5_Paint(object sender, PaintEventArgs e)
        {
            //创建图像对象
            Bitmap bitmap = new Bitmap(300, 200);

            //获取图像的绘制对象
            Graphics graphics = Graphics.FromImage(bitmap);

            //通过图像绘制对象绘制图像
            graphics.DrawEllipse(new Pen(Color.CadetBlue, 5), new Rectangle(10, 10, 60, 60));
            graphics.DrawEllipse(new Pen(Color.Yellow, 5), new Rectangle(40, 40, 60, 60));
            graphics.DrawEllipse(new Pen(Color.Black, 5), new Rectangle(80, 10, 60, 60));
            graphics.DrawEllipse(new Pen(Color.Green, 5), new Rectangle(110, 40, 60, 60));
            graphics.DrawEllipse(new Pen(Color.Red, 5), new Rectangle(150, 10, 60, 60));

            //通过图片控件获取其绘制对象，将图片绘制在图片控件中
            pictureBox1.Image = bitmap;

            //存储到磁盘指定位置
            bitmap.Save("D:/wuhuan.jpg");
        }
    }
}
